package com.tongji.housediy.view
{
	import com.tongji.housediy.model.GoodsModel;
	import com.tongji.housediy.vo.Picture;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import mx.binding.utils.BindingUtils;
	import mx.events.CollectionEvent;
	import mx.events.FlexEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author chenchao
	 * 
	 */
	public class PicSlideMediator extends Mediator
	{
		[Inject]
		public var view:PicSlideView;
		
		[Inject]
		public var model:GoodsModel;
		
		override public function onRegister():void
		{
			BindingUtils.bindProperty(view.picList, "dataProvider", model, "picArray");
			BindingUtils.bindProperty(view.image, "source", model, "previewPicSrc");
			
			view.picList.selectedIndex = 0;
			
			view.picList.addEventListener(MouseEvent.CLICK, listClickHandler);
		}
		
		private function listClickHandler(event:MouseEvent):void
		{
			if (view.picList.selectedItem)
			{
				view.image.source = (view.picList.selectedItem as Picture).pictureSrc;
			}
		}
	}
}